// Package webmanage @author <chengjiang@buffalo-robot.com>
// @date 2023/2/21
// @note
package webmanage

import (
	"context"
	"github.com/go-kratos/kratos/v2/log"
	"gorm.io/gorm"
	"phm/models/generator/model"
)

type SysRoleRepo interface {
	CreateSysRole(ctx context.Context, uModel *model.SysRole, db *gorm.DB) error
	UpdateSysRole(ctx context.Context, uModel *model.SysRole, db *gorm.DB) error
	DeleteSysRoleByIds(ctx context.Context, ids []string, db *gorm.DB) error
	GetSysRoleById(ctx context.Context, id string) (*model.SysRole, error)
	GetSysRoleByIds(ctx context.Context, ids []string) ([]*model.SysRole, error)
	// GetDB 得到db以方便事务处理
	GetDB() *gorm.DB
	// GetSysRoleByUserId  bind relation:
	GetSysRoleByUserId(ctx context.Context, userId string) ([]*model.SysRole, error)
}

type SysRoleUseCase struct {
	role SysRoleRepo
	log  *log.Helper
}

func NewSysRoleUseCase(role SysRoleRepo, logger log.Logger) *SysRoleUseCase {
	return &SysRoleUseCase{
		role: role,
		log:  log.NewHelper(logger),
	}
}
